﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;

namespace Kokomo.Controls
{
	public class BindableResourceElement : Decorator
	{


		public ResourceDictionary ResourcesBinding
		{
			get { return (ResourceDictionary)GetValue(ResourcesBindingProperty); }
			set { SetValue(ResourcesBindingProperty, value); }
		}

		// Using a DependencyProperty as the backing store for ResourcesBinding.  This enables animation, styling, binding, etc...
		public static readonly DependencyProperty ResourcesBindingProperty =
			DependencyProperty.Register("ResourcesBinding", typeof(ResourceDictionary), typeof(BindableResourceElement), new UIPropertyMetadata(null, OnResourceBindingChanged));



		private static void OnResourceBindingChanged(DependencyObject target, DependencyPropertyChangedEventArgs e)
		{
			BindableResourceElement view = (BindableResourceElement)target;
			view.Resources = (ResourceDictionary)e.NewValue;
		}
	}
}
